<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: huajie <banhuajie@163.com>
// +----------------------------------------------------------------------
namespace Admin\Controller;
use Admin\Model\AuthGroupModel;
use Think\Page;

require_once './lib/function.inc.php';
require_once './lib/AopSdk.php';
require_once './lib/aop/request/AlipayMarketingCampaignCashCreateRequest.php';
require_once './lib/HttpRequst.php';

/**
 * 后台报名信息管理控制器
 * @author huajie <banhuajie@163.com>
 */
class AliMobanController extends AdminController {



    /**模板管理
     */
    public function index(){

        $Model   =   M('moban');
        $list = $this->lists($Model,array(),'id desc',array(),true,50);
        $this->assign('_list', $list);
        $this->meta_title = '模板列表';
        $this->display();
    }


   //领取模板
    public function add(){
        $this->meta_title = '领取模板';
        $this->display('edit');
    }




    /**支付宝账号管理
     */
    public function Acount(){

        $Model   =   M('ali_number');
        $list = $this->lists($Model,array(),'id desc',array(),true,50);

        $this->assign('_list', $list);
        $this->meta_title = '账号列表';
        $this->display();
    }


    public function addAcount(){
        $this->meta_title = '创建账号信息';
        $this->display('editacount');
    }



    //编辑
    public function editAcount(){
        $id=I('get.id');
        $data=M('ali_number')->where(array('id'=>$id))->find();
        $this->assign('info',$data);
        $this->meta_title = '编辑信息';
        $this->display('editacount');
    }


    //保存
    public function saveAcount(){
        $data=I('post.');
        if(empty($data)){
            $this->error ("请填写完整数据");
        }

        if(empty($data['id'])){ //新增数据
            $id    = M('ali_number')->add($data);
            if(!$id){
                $this->error ("新增出错");
            }else{
                $this->success ('新增成功！', U('Acount'));
            }
        } else { //更新数据
            $status = M('ali_number')->save($data);
            if(false === $status){
                $this->error ("更新出错");
            }else{
                $this->success ('更新成功！', U('Acount') );
            }
        }
    }

      public function changeStatus(){
        $id=I('get.id');
        $status=I('get.status');
        if(empty($id)){
            $this->error ("请填写完整数据");
        }
       $re = M('ali_number')->where(array('id'=>$id))->setField('status',$status);
       if(false === $re){
             $this->error ("启动出错");
        }else{
            $this->success ('启动成功！', U('Acount') );
       }

    }

    public function deleteAcount(){
        $id = array_unique((array)I('ids',0));
        $id = is_array($id) ? implode(',',$id) : $id;
        if ( empty($id) ) {
            $this->error('请选择要操作的数据!');
        }
        $map['id'] =   array('in',$id);
        $re = M('ali_number')->where($map)->delete();
        if($re!==false){
            $this->success("删除成功");
        }else{
            $this->error("删除失败");
        }
    }


    public function userlist(){
        $Model   =   M('ali_user');
        $list = $this->lists($Model,array(),'id desc',array(),true,50);

        $this->assign('_list', $list);
        $this->meta_title = '关注用户列表';
        $this->display();
    }

    public function sendMsg(){
        $moban=M('moban')->select();
        $this->assign('moban', $moban);
         $this->assign('to_user_id', I('get.user_id'));
        $this->meta_title = '发送消息';
        $this->display();
    }





}
